<template>
  <el-dialog :close-on-click-modal='false' v-drag :title="$t('查看黑名单')" :v-if="dialogVisible" :visible.sync="dialogVisible" width="500px" @close='close'>
    <el-table :data="blackList" size='mini' border default-expand-all max-height="500px">
      <el-table-column prop="defense_type" align="center" :label="$t('防御类别')">
      </el-table-column>
      <el-table-column prop="ip" align="center" :label="$t('IP地址')">
      </el-table-column>
    </el-table>
    <!-- <div class="page">
      <el-pagination :current-page="record.page" :page-size="record.limit" layout="total, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div> -->
    <span slot="footer" class="dialog-footer">
      <el-button @click="close" class="addClose">{{$t('取 消')}}</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getCategoryBlack } from '@/api/safe/ddos'
export default {
  name: 'BlackDialog',
  data () {
    return {
      dialogVisible: false,
      record: {
        name: ''
        // page: 1,
        // limit: 20
      },
      recordCopy: {
        name: ''
        // page: 1,
        // limit: 20
      },
      blackList: []
      // total: 0
    }
  },
  methods: {
    // handleSizeChange (val) {
    //   this.record.limit = val
    //   this.listData()
    // },
    // handleCurrentChange (val) {
    //   this.record.page = val
    //   this.listData()
    // },
    init (data) {
      this.dialogVisible = true
      this.record.name = data.name
      this.listData()
    },
    listData () {
      getCategoryBlack(this.record).then(res => {
        if (res.status === 0) {
          this.blackList = res.info
        }
      })
    },
    close () {
      this.dialogVisible = false
      this.blackList = []
      this.record = Object.assign({}, this.recordCopy)
    }
  }
}
</script>
